// $Id$

// Copyright by Johannes Sixt
// This file is under GPL, the GNU General Public Licence

#ifndef PgmArgs_included
#define PgmArgs_included

#include <qdialog.h>
#include <qlabel.h>
#include <qlineedit.h>
#include <qpushbutton.h>
#include <qlayout.h>
#include <q3listview.h>
#include <q3listbox.h>
#include <q3dict.h>
//Added by qt3to4:
#include <Q3HBoxLayout>
#include <Q3VBoxLayout>
#include "envvar.h"

class QStringList;

class PgmArgs : public QDialog
{
    Q_OBJECT
public:
    PgmArgs(QWidget* parent, const QString& pgm, Q3Dict<EnvVar>& envVars,
	    const QStringList& allOptions);
    virtual ~PgmArgs();

    void setArgs(const QString& text) { m_programArgs.setText(text); }
    const char* args() const { return m_programArgs.text().toAscii().constData(); }
    void setOptions(const QStringList& selectedOptions);
    QStringList options() const;
    void setWd(const QString& wd) { m_wd.setText(wd); }
    QString wd() const { return m_wd.text(); }
    Q3Dict<EnvVar>& envVars() { return m_envVars; }

protected:
    Q3Dict<EnvVar> m_envVars;

    void initEnvList();
    void parseEnvInput(QString& name, QString& value);
    void modifyVar(bool resurrect);

    QLabel m_label;
    QLineEdit m_programArgs;
    QPushButton m_fileBrowse;
    QLabel m_optionsLabel;
    Q3ListBox m_options;
    QLabel m_wdLabel;
    QLineEdit m_wd;
    QPushButton m_wdBrowse;
    QLabel m_envLabel;
    QLineEdit m_envVar;
    Q3ListView m_envList;
    QPushButton m_buttonOK;
    QPushButton m_buttonCancel;
    QPushButton m_buttonModify;
    QPushButton m_buttonDelete;
    Q3HBoxLayout m_layout;
    Q3VBoxLayout m_edits;
    Q3VBoxLayout m_buttons;
    Q3HBoxLayout m_pgmArgsEdit;
    Q3HBoxLayout m_wdEdit;

protected slots:
    void modifyVar();
    void deleteVar();
    void envListCurrentChanged(Q3ListViewItem*);
    void accept();
    void browseWd();
    void browseArgs();
};

#endif // PgmArgs_included
